<?php

declare(strict_types=1);

namespace App\Controllers;

use Throwable;

class ApiController extends BaseController
{
    /**
     * Respuesta de errores y excepciones.
     */
    public function error(Throwable $error): void
    {
        $this->respondServerError($error->getTrace(), $error->getMessage());
    }

    /**
     * Respuesta de endpoints que no existen.
     */
    public function notFound(): void
    {
        $this->respondNotFound('No se encontró el endpoint');
    }

    /**
     * Respuesta de bienvenida de la api.
     */
    public function welcome(): void
    {
        $this->respond([
            'name' => 'minibox',
            'description' => 'Una mini solución de cloud escrito en PHP',
            'documentation' => 'https://ricardogj08.github.io/minibox',
            'repository' => 'https://notabug.org/ricardogj08/minibox',
            'license' => 'AGPL-3.0-or-later',
            'author' => [
                'fullname' => 'Ricardo García Jiménez',
                'email' => 'ricardogj08@riseup.net',
                'resume' => 'https://ricardogj08.github.io/cv',
                'homepage' => 'https://ricardogj08.github.io/blog',
                'linkedin' => 'https://www.linkedin.com/in/ricardogj08',
                'repository' => 'https://notabug.org/ricardogj08',
                'role' => 'Backend developer',
            ],
        ], 'Información acerca de la API RESTful');
    }
}
